package com.epam.DAO.impl;

import javax.ejb.Stateless;
import javax.interceptor.Interceptors;
import javax.persistence.TypedQuery;

import com.epam.DAO.UserDAO;
import com.epam.entity.User;
import com.epam.utils.Interceptor;

@Interceptors(Interceptor.class)
@Stateless
public class UserDAOImpl extends GenericDAOImpl<User> implements UserDAO {

	public UserDAOImpl() {
		super(User.class);
	}

	@Override
	public User read(String login, String pass) {
		TypedQuery<User> query = em
				.createQuery(
						"SELECT u FROM User u WHERE u.login = :login AND u.pass =: pass",
						User.class);
		query.setParameter("login", login);
		query.setParameter("pass", pass);
		User user = query.getSingleResult();
		return user;
	}

}
